//
//  ShenfenrenzhengViewController.m
//  YSZC
//
//  Created by 张斌 on 16/4/15.
//  Copyright © 2016年 YueShiKeJi. All rights reserved.
//

#import "ShenfenrenzhengViewController.h"
#import "YSDoViewManager.h"
#import "LoadVcManager.h"
#import "takePhoto.h"

@interface ShenfenrenzhengViewController ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *view1;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *view2;

@property (weak, nonatomic) IBOutlet UITextField *text1;
@property (weak, nonatomic) IBOutlet UITextField *text2;

@property (weak, nonatomic) IBOutlet UIButton *renzhengbtn;
@property (weak, nonatomic) IBOutlet UIButton *shouchishenfenzhengbtn;
@property (weak, nonatomic) IBOutlet UIButton *shengfenzhengzhengmianbtn;

@property (weak, nonatomic) IBOutlet UIButton *shenfenzhengfanmian;

@property (assign,nonatomic)int a;
@end

@implementation ShenfenrenzhengViewController
- (IBAction)shouchishenfenzhengbtnclick:(UIButton*)sender {

    [self selectandsetpictureWithbtn:sender];
    
}
- (IBAction)shenfenzhengzhengmianbtnclick:(UIButton*)sender {
     [self selectandsetpictureWithbtn:sender];
}
- (IBAction)shenfenzhengfanmiancbtnclick:(UIButton*)sender {
     [self selectandsetpictureWithbtn:sender];
}

- (IBAction)renzhengbtnclick:(UIButton*)sender {
    
    sender.selected = YES;
    [sender setBackgroundColor:[UIColor colorWithRed:193/255.0 green:193/255.0 blue:193/255.0 alpha:1]];
    
}

// 选择并设置图片的方法
-(void)selectandsetpictureWithbtn:(UIButton*)btn{
    [takePhoto sharePicture:^(UIImage *image) {
        [btn setImage:image forState:UIControlStateNormal];
    } :^(UIImagePickerController *pickerVc) {
        [self presentViewController:pickerVc animated:YES completion:nil];
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.a = 2;


    // 每次进到这个控制器判断认证状态
    if ((self.a == 1)) {
        // 还没认证
        
    }else if ((self.a == 2)) {
        // 正在审核
        [self renzhengbtnclick:self.renzhengbtn];
        
    }else if ((self.a == 3)){
        //认证成功
        self.renzhengbtn.hidden = YES;
    }else if (self.a == 4){
        // 认证失败,弄个弹窗就行了
        // 提示用户,要想成为领头人，去网页
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"审核失败,请使用正确的姿势" preferredStyle:UIAlertControllerStyleAlert];
        
        UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            
            // 清空所有东西
            self.text1.text = @"";
            self.text2 .text = @"";
            [self.shouchishenfenzhengbtn setImage:[UIImage imageNamed:@"s1"] forState:UIControlStateNormal];
            [self.shengfenzhengzhengmianbtn setImage:[UIImage imageNamed:@"s2"] forState:UIControlStateNormal];
            [self.shenfenzhengfanmian setImage:[UIImage imageNamed:@"s3"] forState:UIControlStateNormal];
            
            self.renzhengbtn.selected = NO;
            [self.renzhengbtn setBackgroundColor:[UIColor colorWithRed:249/255.0 green:60/255.0 blue:71/255.0 alpha:1]];
            

        }];
        
        
        [alert addAction:action1];
        
        [self presentViewController:alert animated:YES completion:^{
        }];
        
    }
   }

- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    
    [[YSDoViewManager sharedmanager] setlineWithViews:@[self.view1,self.view2]];
    
    [[YSDoViewManager sharedmanager] settoyuanWithview:@[self.renzhengbtn]];
    

    
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}
- (IBAction)leftbuttonclick:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
// 申请认证
- (IBAction)shenqingrenzhengbtnclick:(id)sender {
    [self.navigationController pushViewController:[LoadVcManager sbVCWithsbname:@"AddbankcardViewController"] animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
